﻿window.onerror=function(){
	return true;
}
document.write=function(){
	return false;
}
window.open=function(url,type){
	var a=document.getElementById("open_method_moni");
	if(a==null){
		a=document.createElement("a");
		a.innerHTML="open";
		a.id="open_method_moni";
		a.style.cssText="position:absolute;top:-100px;"
		document.body.appendChild(a);
	}
	a.href=url;
	a.target=type;
	a.click();
}
function qingshu(json,repeat,player,player_str,time){
		this.json=json;
		qingshu.args=this;
		this.type=repeat;
		this.mp3=player;//背景音乐
		this.time=time==null?290:time;//迭代间隔
		this.i=0;//板块迭代器
		this.p=0;//段落迭代器
		this.json_arr=new Array();//板块存放数组
		this.reg=/[\,.;'":]/;
		for(var name in this.json){
			if(this.json.hasOwnProperty(name))
				this.json_arr.push(name);
		}
		if(this.type=="one"||this.type=="one_one"){
			setTimeout(function(){
				qingshu.args.mp3.play();
			},2000);
			if(this.type=="one_one"){
				this.mp3.loop(player_str);
			}
		}
		this.json_len=this.json_arr.length;//板块长度
		if(typeof this.addText!="function"){
			if(this.type=="one"||this.type=="none"||this.type=="one_one"){
				qingshu.prototype.addText=function(elem,o_char){
					elem.innerHTML+=o_char;
					if(this.reg.test(o_char)){
						wait();
					}
				}
			}else if(this.type=="repeat"){
				qingshu.prototype.addText=function(elem,o_char){
					elem.innerHTML+=o_char;
					this.mp3.play();
					if(this.reg.test(o_char)){
						wait();
					}
				}
			}
			
		}
		if(typeof this.addContent!="function"){
			qingshu.prototype.addContent=function(elem,str,func){
				var i=0,len=str.length;
				setTimeout(function(){
				if(i<len){
					qingshu.args.addText(elem,str.charAt(i));
					i++;
					setTimeout(arguments.callee,qingshu.args.time);
				}else{
					func();
				}
				},qingshu.args.time);
			}
		}
		if(typeof this.write!="function"){
			qingshu.prototype.write=function(){
				if(this.i==this.json_len){return;}
				var name=this.json_arr[this.i];
				switch(name){
					case "pp":
						var p_len=this.json[name].length;
						var final=document.getElementById("final");
						var div= document.createElement("div");
						var parent=final.parentNode;
						var last=parent.lastChild;
						parent.insertBefore(div,final);
						div.className="pp";
						qingshu.args.addContent(div,this.json[name][this.p],function(){
							if(qingshu.args.p==p_len-1){
								qingshu.args.i++;
							}else{
								qingshu.args.p++;
							}
							qingshu.args.write();
						});
						break;
					default:
						var header=document.getElementById(name);
						qingshu.args.addContent(header,this.json[name],function(){
							qingshu.args.i++;
							qingshu.args.write();
						});
						break;
				}
			}
		}
		if(typeof this.display!="function"){
			qingshu.prototype.display=function(){
				if(this.i==this.json_len){return;}
				var name=this.json_arr[this.i];
				switch(name){
					case "pp":
						var p_len=this.json[name].length;
						var final=document.getElementById("final");
						var div= document.createElement("div");
						var parent=final.parentNode;
						var last=parent.lastChild;
						parent.insertBefore(div,final);
						div.className="pp";
						div.innerHTML=this.json[name][this.p];
						if(this.p==p_len-1){
							this.i++;
						}else{
							this.p++;
						}
						this.display();
						break;
					default:
						var header=document.getElementById(name);
						header.innerHTML=this.json[name];
						this.i++;//这个当时写的时候放在了this.display()的后面,弄成了死循环
						this.display();
						break;
				}
				
			}
		}
	}
function wait(){
	for(var i=0;i<30000;i++){
		for(var j=0;j<250;j++){
			
		}
	}
}
//文本框跳动函数
function jump(elem){
	jump.names=this;
	this.elem=elem;
	this.timer=null;
	this.i=0;
	if(typeof this.h_jump!="function"){
		jump.prototype.h_jump=function(){
			with(this){
				timer=setInterval("jump.names._jump()",60);
			}
		}
	}
	if(typeof this._jump!="function"){
		jump.prototype._jump=function(){
			with(this){
				i++;
				switch(i){
				case 1:elem.style.position="relative";elem.style.left="8px";break;
				case 2:elem.style.left="0px";break;
				case 3:elem.style.left="-8px";break;
				case 4:elem.style.left="0px";clearInterval(timer);elem.style.position="static";break;
				default:new Error("出错了");break;
				}
			}
		}
	}
}
//添加事件
function addEvent(elem,type,func){
	if(elem.addEventListener){
		elem.addEventListener(type,func,false);
	}else if(elem.attachEvent){
		elem.attachEvent("on"+type,func);
	}else{
		elem["on"+type]=func;
	}
}
//阻止默认事件
function preventDefault(event){
	event=window.event?window.event:event;
	if(event.preventDefault){
		event.preventDefault();
	}else{
		event.returnValue=false;
	}
}
//ajax请求
function get_ajax(url,param,func,type){
	if(param){
		for(var i in param){
			url+=url.indexOf("?")==-1?"?":"&";
			url+=i+"="+param[i];
		}
	}
	var xhr=new XMLHttpRequest();
	xhr.onreadystatechange=function(){
		if(xhr.readyState==4){
			if(xhr.status>=200&&xhr.status<300||xhr.status==304){
				func(xhr.responseText);
			}
		}
	}
	xhr.open("get",url,type)
	xhr.send(null);
}
function post_ajax(url,param,func,type){
	if(param){
		for(var i in param){
			url+=url.indexOf("?")==-1?"?":"&";
			url+=i+"="+param[i];
		}
	}
	var xhr=new XMLHttpRequest();
	xhr.onreadystatechange=function(){
		if(xhr.readyState==4){
			if(xhr.status>=200&&xhr.status<300||xhr.status==304){
				func(xhr.responseText);
			}
		}
	}
	xhr.open("post",url,type)
	xhr.send(null);
}
//验证码
function yzm(y_id,option){
	detail={
		width:60,
		height:20
	};//初始化参数
	var yzm="";
	var elem=document.getElementById(y_id);
	elem.style.cssText="margin-left:10px;border:1px solid #333;cursor:pointer;display:inline-block;position:relative;-moz-user-focus:ignore;-moz-user-input:disabled;-moz-user-select:none;";
	elem.style.width=detail.width+"px";
	elem.style.height=detail.height+"px";
	elem.style.lineHeight=detail.height+"px";
	elem.onselectstart=function(){return false;};
	var t_width=detail.width/4;
	var t_offset=Math.ceil(detail.height/4);//-------------字母的偏移范围
	var prev_offset=Math.floor(detail.height/3);
	for(var i=0;i<4;i++){
		//字母在竖直方向的随机偏移量
		var offset=Math.ceil(Math.random()*t_offset-Math.random()*t_offset);
		var t=document.createElement("span");
		t.style.display="inline-block";
		t.style.width=t_width+"px";
		t.style.position="relative";
		t.style.top=offset+"px";
		var text=Math.ceil(Math.random()*16).toString(16);
		text=text!=10?text:text-1
		t.innerHTML=text;
		elem.appendChild(t);
		yzm+=text;
		//添加障碍物
		var prev=document.createElement("span");
		prev.style.position="absolute";
		prev.style.color="red";
		prev.style.opacity=Math.ceil(Math.random())-0.5;
		prev.style.filter="alpha(opacity="+Math.ceil(Math.random()*100)+")";
		prev.style.top=Math.ceil(Math.random()*prev_offset)+"px";
		prev.style.left=Math.floor(Math.random()*detail.width-3)+"px";
		prev.innerHTML="*";
		elem.appendChild(prev);
	}
	return yzm;
}

//取出前后空格
function str_trim(str){
	var reg=/(^\s*)|(\s*$)/g;
	return str.replace(reg,"");
}